package com.alameda.service.impl.info;

import com.alameda.common.utils.ObjectUtils;
import com.alameda.info.dto.JobInfoDTO;
import com.alameda.info.vo.JobLogVO;
import com.alameda.mapper.info.JobInfoMapper;
import com.alameda.pojo.info.JobInfoDO;
import com.alameda.service.info.JobInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 定时任务信息 业务逻辑层 具体实现
 *
 * @author Lv
 * @date 2024/06/10
 */
@Slf4j
@Service
public class JobInfoServiceImpl extends ServiceImpl<JobInfoMapper, JobInfoDO> implements JobInfoService {

    @Autowired
    private JobInfoMapper jobInfoMapper;

    /**
     * 查询定时任务信息
     *
     * @param jobInfoDTO 定时任务信息查询对象
     * @return
     */
    @Override
    public IPage<JobLogVO> listJobInfo(JobInfoDTO jobInfoDTO) {
        // 构造分页对象
        IPage<JobInfoDO> iPage = new Page<>(jobInfoDTO.getPageNum(), jobInfoDTO.getPageSize());
        // 数据提取
        IPage<JobInfoDO> pageData = jobInfoMapper.findJobInfo(iPage, jobInfoDTO.getRemark(), jobInfoDTO.getExecutorHandler());
        return ObjectUtils.convertPageData(pageData, JobLogVO.class);
    }
}
